USE FixedAsset_Star
GO 
IF (SELECT object_id('dbo.Branch_Dim')) > 0
   DROP TABLE dbo.Branch_Dim
CREATE TABLE dbo.Branch_Dim
	(
	BranchKey		int IDENTITY (1,1) NOT NULL,
	BranchID		nchar(5) NOT NULL,
	AddressNumber 	tinyint NOT NULL,
	BranchName		nchar(30) NOT NULL,
	BranchName1		nchar(30) NOT NULL,
	Region			nchar(2) NOT NULL,
	Groups			nchar(3) NOT NULL,
	City			nchar(3) NOT NULL,
	)

IF (SELECT object_id('dbo.Department_Dim')) > 0
   DROP TABLE dbo.Department_Dim
CREATE TABLE dbo.Department_Dim
	(
	DepartmentKey	int IDENTITY (1,1) NOT NULL,
	DepartmentID	nchar(12) NOT NULL,
	DepartmentName	nchar(30) NOT NULL,
	Division		nchar(2) NOT NULL,
	Groups			nchar(3) NOT NULL
	)

IF (SELECT object_id('dbo.FixedAsset_Dim')) > 0
   DROP TABLE dbo.FixedAsset_Dim
CREATE TABLE dbo.FixedAsset_Dim
	(
	FixedAssetKey	int IDENTITY (1,1) NOT NULL,
	FixedAssetID	NCHAR(12) NOT NULL,
	FixedAssetName	NCHAR(30) NOT NULL,
	UnitNumber		SMALLINT NOT NULL,
	ParentNumber	SMALLINT NOT NULL,
	Description1	NCHAR(30) NOT NULL,
	Description2	NCHAR(30) NOT NULL
	)

IF (SELECT object_id('dbo.Time_Dim')) > 0
   DROP TABLE dbo.Time_Dim
CREATE TABLE dbo.Time_Dim
	(
	TimeKey		int IDENTITY (1,1) NOT NULL,
	TheDate		date NOT NULL,
	DayOfWeek	nchar(20) NOT NULL,
	Month		int NOT NULL,
	Year		int NOT NULL,
	Quarter		int NOT NULL,
	DayOfYear	int NOT NULL,
	Holiday		nchar(1) NOT NULL,
	Weekend		nchar(1) NOT NULL,
	YearMonth	nchar(16) NOT NULL,
	WeekOfYear	int NOT NULL
	)
 	
USE FixedAsset_Star
GO 
ALTER TABLE dbo.Time_Dim WITH NOCHECK ADD
	CONSTRAINT PK_Time_Dim
		PRIMARY KEY NONCLUSTERED(TimeKey)

 	
ALTER TABLE dbo.Branch_Dim WITH NOCHECK ADD
	CONSTRAINT PK_Branch_Dim
		PRIMARY KEY NONCLUSTERED(BranchKey)

ALTER TABLE dbo.Department_Dim WITH NOCHECK ADD
	CONSTRAINT PK_Department_Dim
		PRIMARY KEY NONCLUSTERED(DepartmentKey)

ALTER TABLE dbo.FixedAsset_Dim WITH NOCHECK ADD
	CONSTRAINT PK_FixedAsset_Dim
		PRIMARY KEY NONCLUSTERED(FixedAssetKey)
GO